<!DOCTYPE html>
<html lang="zh_CN">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>

</body>
<script type="text/javascript">
    var string1 = 'a12bca24sfad45sf34'; // [12, 24, 45, 34]
    /**
     * 编程思路分析：
     * 1. 将字符串中的每个字符取出来，判断一个下是否是数字字符 '0'-'9'
     * 如果是则继续向下判断，如果是进行拼接，如果不是，则进行保存
     *
     */

    var rs = [];
    var _number = '';

    for (var i = 0; i < string1.length; i++) {

        var tmp = string1.charAt(i);

        if (tmp >= '0' && tmp <= '9') {
            _number += tmp;
        } else {
            if (_number != '') {
                rs.push(_number);
                _number = '';
            }
        }
    }

    if (_number != '') {
        rs.push(_number);
        _number = '';
    }

    console.log(rs);
</script>

</html>
